<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var names = ["abc", "cba", "nba", "mba"]
    // 1.slice
    var newNames = names.slice(0, 2)
    var newNames1 = [].slice.apply(names, [1, 3])
    console.log(names)
    console.log(newNames)
    console.log(newNames1)

    // 2.splice:操作数组的利器(不是纯函数)
    names.splice(2, 3)
    console.log(names)
  </script>
</body>

</html>